IMoniker - Class Moniker Implementation

Class monikers are monikers that represent an object class. Class monikers bind to the class object of the class for which they are created.

Class monikers are most useful in composition with other types of monikers, such as file monikers or item monikers. Class monikers may also be composed to the right of monikers supporting binding to the IClassActivatorB21H7_ interface. This allows IClassActivator to provide access to the class object and instances of the class.

When to Use

To use class monikers, you must use the CreateClassMoniker11Q3NK3 function to create the monikers.

Remarks

IMoniker::BindToObject486P_PV

If pmkLeft is NULL, calls CoGetClassObject2_47ZR8 using the CLSID the class moniker was initialized with (in CreateClassMoniker or through MkParseDisplayName) and the CLSCTX of the current pbc (IBindContext).

If pmkLeft is non-NULL, calls pmkLeft->BindToObject for IClassActivatorB21H7_ and calls IClassActivator::GetClassObject5_K._G8 with the CLSID it was initialized with and the CLSCTX and LOCALE parameters from of the current pbc (IBindContext).

This process is very roughly sketched out in the following code:

    BIND_OPTS2    bindOpts;

    IClassActivator *pActivate;

 

    bindOpts.cbStruct = sizeof(bindOpts);

    pbc->GetBindOptions(&bindOpts);

 

    if (NULL == pmkToLeft)

        return CoGetClassObject(<clsid>, bindOpts.dwClassContext, NULL, riid, ppvResult);

 

    pmkToLeft->BindToObject(pbc, NULL, IID_IClassActivator, (void **) &pActivate);

    hr = pActivate->GetClassObject(<clsid>, bindOpts.dwClassContext, bindOpts.locale, iid, ppvResult);

    pActivate->Release();

    return hr;

 

IMoniker::BindToStorageCA2I.L

This method forwards to the class moniker s BindToObject.

IMoniker::Reduce.M4QZ4

This method returns MK_S_REDUCED_TO_SELF and passes back the same moniker.

IMoniker::ComposeWith1M9Y_YZ

Follows the contract, and behaves like an Item Moniker in that it can return E_INVALIDARG and MK_E_NEEDGENERIC, etc.

IMoniker::Enum18FKHOZ

This method returns S_OK and sets ppenumMoniker to NULL. May return E_INVALIDARG if ppenumMoniker is an invalid pointer.

IMoniker::IsEqualJ2_C.R

This method returns S_OK if pmkOther is a class moniker constructed with the same CLSID information as itself. Otherwise, the method returns S_FALSE. May return E_INVALIDARG if pmkOther is an invalid pointer.

IMoniker::HashF_B.6E

This method calculates a hash value for the moniker and returns S_OK. may return E_INVALIDARG if pdwHash is an invalid pointer.

IMoniker::IsRunning1CR3B7K

Returns E_NOTIMPL.

IMoniker::GetTimeOfLastChange123HWA2

Returns MK_E_UNAVAILABLE.

IMoniker::Inverse4HON_YU

This method returns an anti-moniker (i.e., the results of calling CreateAntiMonikerK5IP0Q).

IMoniker::CommonPrefixWithK6I29R

If pmkOther IsEqual to this moniker, retrives a pointer to this moniker and returns MK_S_US. If pmkOther is a class moniker but is not equal to this moniker, returns MK_E_NOPREFIX. Otherwise returns the result of calling MonikerCommonPrefixWith1N7XSDT with itself as pmkThis, pmkOther and ppmkPrefix, which handles the case whre pmkOther is a generic composite moniker.

IMoniker::RelativePathTo8ECMZ1

This method returns the result of calling This method returns the result of calling MonikerRelativePathToK59NF_ with pmkSrc equal to this moniker, pmkOther, ppmkRelPath, and TRUE as dwReserved.

IMoniker::GetDisplayName2BE2_IB

The display name for class monikers is of the form:

display-name =  CLSID:  string-clsid-no-curly-braces *[ ;  clsid-options]  : 

clsid-options = clsid-param  =  value

clsid-param = none currently defined

Example:

clsid:a7b90590-36fd-11cf-857d-00aa006d2ea4:

IMoniker::ParseDisplayNameAU2GHS

This method parses the display name by binding to itself for IParseDisplayName and asking the bound object to parse the display name into a moniker, as follows:

    hr = BindToObject(pbc, pmkToLeft, IID_IParseDisplayName, (void**)&ppdn);

    if (SUCCEEDED(hr)) { 

        hr = ppdn->ParseDisplayName(pbc, lpszDisplayName, pchEaten, ppmkOut);

        ppdn->Release();

        }

    return hr;

This method tries to acquire an IParseDisplayNameQD_Z28 pointer, first by binding to the class factory for the object identified by the moniker, and then by binding to the object itself. If either of these binding operations is successful, the file moniker passes the unparsed portion of the display name to the IParseDisplayName::ParseDisplayNameLEMM77 method.

This method returns MK_E_SYNTAX if pmkToLeft is non-NULL.

IMoniker::IsSystemMonikerXEHS5E

This method returns S_OK, and passes back MKSYS_CLASSMONIKER.

See Also

CreateClassMoniker, IMoniker